package com.taptech.doufu.util;

import android.os.Environment;

import java.io.File;

/**
 * Created by Administrator on 2017/4/28/028.
 */
public class DiaoBaoPath {
    /**
     * 获取SD卡的绝对路径
     * @return
     */
    public static String getSDPath()
    {
        File sdDir = null;
        boolean sdCardExist = Environment.getExternalStorageState()
                .equals(android.os.Environment.MEDIA_MOUNTED);//判断sd卡是否存在
        if(sdCardExist)
        {
            sdDir = Environment.getExternalStorageDirectory();//获取跟目录
        }
        if(sdDir!=null)
        {
            return sdDir.toString();
        }
        else
        {
            return "";
        }
    }

    /**
     * 根目录文件夹
     * @return
     */
    public static String getDiaobaoRootPath()
    {
        StringBuilder path=new StringBuilder();
        path.append(getSDPath()).append("/doufulog");
        return path.toString();
    }

    /**
     * 图片文件夹
     * @return
     */
    public static String getDiaobaoImagePath()
    {
        StringBuilder path=new StringBuilder();
        path.append(getSDPath()).append("/doufu/image");
        return path.toString();
    }

    /**
     * 创建log文件
     */
    public static void createRootFolder()
    {
        //根目录
        File file=new File(getDiaobaoRootPath());
        if(!file.exists() && !file.isDirectory())
        {
            file.mkdirs();
        }
    }

    /**
     * 获取异常文件路径
     * @return
     */
    public static String getErrorLogPath()
    {
        String path=new StringBuilder(getDiaobaoRootPath()).append("/log.xml").toString();
        return path;
    }
}
